function stumps = getDataStumps()   
    
    clear all;
    close all;
    clc;
    
    %fileName = 'LiftToEar-CK';    
    load subjectKey;
    load activityKey;
    
    % Window Size - make sure it's an even value
    windowSize = 100;
    
    % Number of iterations for Adaboost.
    nIter = 150;
    
    % Normalize the train data?
    fnorm = false;
    
    % Number of Labels
    nLabels = length(activityKey);
    
    % Number of subjects
%     nSubs = length(subjectKey);
    nSubs = 5;
    
    tic;
    for subj=1 : nSubs %#ok<USENS>
        feat = [];
        label = [];
        for act=1 : nLabels %#ok<USENS>
            % Set the filenames and variable names to be used
            fileName = sprintf('%s-%s',activityKey{act},subjectKey{subj});
            load(sprintf('../%s-0.txt',fileName));
            load(sprintf('../%s-1.txt',fileName));
            load(sprintf('../annotation/%s.txt',fileName));

            % Extract data
            varName = fileName;
            varName(find(varName == '-')) = '_';
            actName = substring(varName, 0, find(varName == '_',1)-2);

            data1 = eval(sprintf('%s_0',varName));
            data2 = eval(sprintf('%s_1',varName));
            annotation = eval(varName);

            % Extract current label of activity
            activityLabel = 0;
            for i=1:nLabels
                if strcmp(activityKey{i}, actName)
                    activityLabel = i;
                    break;
                end;
            end

            % Extract features for every 100 samples with 50 samples overlapping
            % from both the accelerometer data
            index = 1;           
            for i=1:(0.5*windowSize):size(data1,1)
                i_end = i+windowSize-1;
                if i_end > size(data1,1)
%                     i_end = size(data1,1);
                    break;
                end;
                tmp_feat = computestatfeatures([data1(i:i_end,:),data2(i:i_end,:)]);
                tmp_label = 0;
                if index <= size(annotation,1)
                    if i >= annotation(index,1) && i <= annotation(index,2)
                        tmp_label = activityLabel;
                    elseif i > annotation(index,2)
                        % Increase index values for annotation, reduce i by 50 and 
                        % come back. This eliminates an extra index within bounds 
                        % check for annotation matrix
                        index = index+1;
                        i = i-(0.5*windowSize); 
                    end;
                end;               
                feat = [feat;tmp_feat];
                label = [label;tmp_label];
            end;
        end;
        save(sprintf('feat%d.mat',subj),'feat','label');
    end;    
    disp('Finished Extracting Features');toc;disp(' ');
%% Adaboost Training and Classification
stumps = {};
for fold = 1 : nSubs
    % Create the train and test data set.
    trdata = [];
    trlabel = [];
    tstdata = [];
    tstlabel = [];
    
    for j = 1 : nSubs
        load(sprintf('feat%d.mat',j));
        % Subject Independent
        if fold == j
            tstdata = feat;
            tstlabel = label;
        else
            trdata = [trdata;feat];
            trlabel = [trlabel;label];
        end       
    end
  
    % normalize the training and the test data.
    if fnorm
        [trdata maxc minc] = normalizedata(trdata);
        [tstdata maxc minc] = normalizedata(tstdata, maxc, minc);
    end
    
   % Create the binary boosted classifiers for each of the actions.
   act_model{fold} = trainadaboost(trdata,trlabel,nLabels,nIter);
    
   
   % Multi class model evaluation with test data.    
   [error(fold) accuracy(fold) yest{fold} stumps{fold}] = eval_multiclass_boost(tstdata,tstlabel,act_model{fold},nIter);
    
   disp(sprintf('Finished running Fold %d. Accuracy calculated %f',fold,accuracy(fold)));toc;disp(' ');
end

%% Computestatfeatures
% computes mean, variance, correlation, energy and entropy
function feature = computestatfeatures(data)

% mean of the data
m = mean(data);

% variance of the data
v = var(data);

% correlation between the axis.
c = corr(data);

% absolute value of the fourier transform.
fftdata = abs(fft(data));

% remove the mean value.
fftdata = fftdata(2:end,:);

% energy.
e = sum(fftdata.^2)/size(fftdata,1);

% spectral entropy
fftdata = 1 + fftdata/size(data,1);
temp = [fftdata(:,1)/sum(fftdata(:,1)), fftdata(:,2)/sum(fftdata(:,2)),...
                                        fftdata(:,3)/sum(fftdata(:,3)),...
                                        fftdata(:,4)/sum(fftdata(:,4))...
                                        fftdata(:,5)/sum(fftdata(:,5))...
                                        fftdata(:,6)/sum(fftdata(:,6))];
ent = -sum(temp.*log(temp),1);

%feature = [m v c(1,2) c(1,3) c(2,3) e ent];
feature = [m v c(1,2:6) c(2,3:6) c(3,4:6) c(4,5:6) c(5,6) e ent];
if(length(feature) ~= 39)
    disp('will this work?');
end
return;    
